﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class post : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["USER"] == null)
            {
              
                Response.Redirect("bbs.aspx");
            }
            if(Session["CLASSID"]==null)
            {
                Response.Write("<script LANGUAGE='javascript'>alert('请先选择主题！')</script>");
                Response.Redirect("bbs.aspx");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            study.BLL.tb_bbs_note rebll = new study.BLL.tb_bbs_note();
            study.Model.tb_bbs_note remod = new study.Model.tb_bbs_note();
            study.Model.tb_user usermod = new study.Model.tb_user();
            study.BLL.tb_user userbll = new study.BLL.tb_user();
            usermod = (study.Model.tb_user)Session["USER"];
            remod.userId = usermod.ID;
            remod.class_id =int.Parse( Session["CLASSID"].ToString());
            remod.post_time = DateTime.Now.ToString();
            remod.title = title.Text;
            remod.content = context.Text;
            if (rebll.Add(remod)!=0)
                Response.Write("<script>alert('发表成功！');</script>");
            usermod.count += 1;
            userbll.Update(usermod);
            Response.Redirect("bbs.aspx");
        }
    }
}